package com.mjf.cjt.enums;

import cn.hutool.core.collection.ListUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * desc  天发API枚举
 * </p>
 *
 * @author chenshoumeng
 * @date 2025/5/18 02:00
 */
@Getter
public enum TFApiEnum {

    TF_API_SALE_DELIVERY_ORDER_LIST_URL("101", "销货单列表查询", "/tplus/api/v2/SaleDeliveryOpenApi/FindVoucherList", ListUtil.of(
        "SaleDelivery.ID",
        "SaleDelivery.Code",
        "SaleDelivery.VoucherDate",
        "SaleDelivery.pubuserdefnvc2",
        "SaleDelivery.Customer.Name",
        "SaleDelivery.Customer.Code",
        "SaleDelivery.Project.Name",
        "SaleDelivery.OrigAmount",
        "SaleDelivery.Customer.Fax",
        "SaleDelivery.Clerk.Code",
        "SaleDelivery.Clerk.Name",
        "SaleDelivery.SaleDeliveryDetails.ID",
        "SaleDelivery.SaleDeliveryDetails.Project.Name",
        "SaleDelivery.SaleDeliveryDetails.OrigDiscountPrice",
        "SaleDelivery.SaleDeliveryDetails.OrigDiscountAmount",
        "SaleDelivery.SaleDeliveryDetails.Quantity",
        "SaleDelivery.SaleDeliveryDetails.DiscountPrice",
        "SaleDelivery.SaleDeliveryDetails.ExpenseAmount",
        "SaleDelivery.SaleDeliveryDetails.Inventory.priuserdefdecm1",
        "SaleDelivery.SaleDeliveryDetails.Inventory.priuserdefdecm2",
        "SaleDelivery.SaleDeliveryDetails.Inventory.Code",
        "SaleDelivery.SaleDeliveryDetails.Inventory.Name",
        "SaleDelivery.SaleDeliveryDetails.Inventory.Specification"
    ), ""),
    TF_API_WAREHOUSE_QUERY_URL("102", "仓库查询", "/tplus/api/v2/warehouse/Query", ListUtil.of(), ""),
    TF_API_INVENTORY_QUERY_PAGE_URL("103", "存货查询", "/tplus/api/v2/inventory/QueryPage", ListUtil.of(),
        "Id,Code,Name,Unit.Name,Specification, InventoryClass.Code,InventoryClass.Name "),
    TF_API_PARTNER_QUERY_URL("104", "往来单位查询", "/tplus/api/v2/partner/Query", ListUtil.of(),
        "ID,Code,Name,Disabled,Ts,Shorthand,PartnerAbbName,PartnerType.ID,PartnerType.Code,PartnerType.Name," +
            "PartnerClass.ID,PartnerClass.Code,PartnerClass.Name"),
    TF_API_PURCHASE_ORDER_LIST_URL("105", "进货单列表查询", "/tplus/api/v2/PurchaseArrivalOpenApi/FindVoucherList", ListUtil.of(
        "PurchaseArrival.ID",
        "PurchaseArrival.VoucherDate",
        "PurchaseArrival.Warehouse.ID",
        "PurchaseArrival.Warehouse.Code",
        "PurchaseArrival.Warehouse.Name",
        "PurchaseArrival.Code",
        "PurchaseArrival.SourceVoucherType.ID",
        "PurchaseArrival.SourceVoucherType.Code",
        "PurchaseArrival.Partner.ID",
        "PurchaseArrival.Partner.Code",
        "PurchaseArrival.Partner.Name",
        "PurchaseArrival.Details.ID",
        "PurchaseArrival.Details.Inventory.Code",
        "PurchaseArrival.Details.Inventory.Name",
        "PurchaseArrival.Details.Inventory.priuserdefdecm1",
        "PurchaseArrival.Details.Inventory.priuserdefdecm2",
        "PurchaseArrival.Details.Quantity",
        "PurchaseArrival.Details.OrigDiscountPrice",
        "PurchaseArrival.Details.OrigDiscountAmount",
        "PurchaseArrival.Details.Unit.Code",
        "PurchaseArrival.Details.Unit.Name"
    ), ""),
    TF_API_ADJUST_COST_IN_CREATE_URL("106", "入库调整单新增", "/tplus/api/v2/AdjustCostInOpenApi/Create", ListUtil.of(), ""),
    TF_API_RECEIVE_VOUCHER_LIST_URL("107", "收款单列表查询", "/tplus/api/v2/ReceiveVoucherOpenApi/FindVoucherList", ListUtil.of(
        "ArapReceivePayment.ID",
        "ArapReceivePayment.VoucherDate",
        "ArapReceivePayment.Code",
        "ArapReceivePayment.Partner.Code",
        "ArapReceivePayment.Partner.Name",
        "ArapReceivePayment.IsReceiveFlag",
        "ArapReceivePayment.BusiType",
        "ArapReceivePayment.Memo",
        "ArapReceivePayment.VoucherState.Code",
        "ArapReceivePayment.ArapMultiSettleDetails.ID",
        "ArapReceivePayment.ArapMultiSettleDetails.OrigAmount",
        "ArapReceivePayment.ArapMultiSettleDetails.SettleStyle.Code",
        "ArapReceivePayment.ArapMultiSettleDetails.SettleStyle.Name",
        "ArapReceivePayment.Details.ID",
        "ArapReceivePayment.Details.VoucherCode",
        "ArapReceivePayment.Details.VoucherType.Code",
        "ArapReceivePayment.Details.VoucherType.Name",
        "ArapReceivePayment.Details.OrigAllowancesAmount",
        "ArapReceivePayment.Details.OrigCurrentAmount"
    ), ""),
    TF_API_PERSON_QUERY_URL("108", "员工查询", "/tplus/api/v2/person/Query", ListUtil.of(),
        "ID,Code,Name,Department.Name,MobilePhoneNo"),
    TF_API_EXPENSE_QUERY_URL("109", "费用档案查询", "/tplus/api/v2/Expense/Query", ListUtil.of(), ""),
    TF_API_MANUFACTURE_ORDER_LIST_URL("110", "生产加工单列表查询", "/tplus/api/v2/ManufactureOrderOpenApi/FindVoucherList" +
        "?idMarketingOrgan=1",ListUtil.of(
        "ManufactureOrder.ID", // 单据ID
        "ManufactureOrder.CreatedTime", // 创建时间
        "ManufactureOrder.VoucherDate", // 单据日期
        "ManufactureOrder.Code", // 单据编号
        "ManufactureOrder.Person.Name", // 业务员
        "ManufactureOrder.pubuserdefnvc7", // 机构销售订单号
        "ManufactureOrder.pubuserdefnvc8", // 机构业务员
        "ManufactureOrder.ManufactureOrderDetails.ID", // 明细行ID
        "ManufactureOrder.ManufactureOrderDetails.SaleOrderCode", // 销售订单号
        "ManufactureOrder.ManufactureOrderDetails.Warehouse.Name", // 预入仓库
        "ManufactureOrder.ManufactureOrderDetails.Inventory.Code", // 产品编码
        "ManufactureOrder.ManufactureOrderDetails.Inventory.Name", // 产品名称
        "ManufactureOrder.ManufactureOrderDetails.Inventory.priuserdefnvc1", // 存货代码
        "ManufactureOrder.ManufactureOrderDetails.Inventory.Specification", // 规格
        "ManufactureOrder.ManufactureOrderDetails.Unit.Name", // 单位
        "ManufactureOrder.ManufactureOrderDetails.Quantity", // 数量
        "ManufactureOrder.ManufactureOrderDetails.pubuserdefnvc2", // 成品尺寸
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.ID", // 材料编码
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Inventory.Code", // 材料编码
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Inventory.Name", // 材料名称
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Inventory.Specification",// 材料规格
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Inventory.Unit.Name",// 材料单位
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Quantity", // 材料数量
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Batch",// 材料数量
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Batch",// 备注
        "ManufactureOrder.ManufactureOrderDetails.ManufactureOrderMaterialDetails.Warehouse.Name"// 材料数量

    ), ""),
     TF_API_DEPARTMENT_QUERY_URL("111", "部门查询", "/tplus/api/v2/Department/Query", ListUtil.of(), "ID,Code,Name,Parent" +
         ".Code,Parent.Name"),
     TF_API_VOUCHER_QUERY_URL("112", "凭证列表查询", "/tplus/api/v2/doc/Query", ListUtil.of(), ""),
    TF_API_PROJECT_QUERY_URL("113", "项目列表查询", "/tplus/api/v2/Project/Query2", ListUtil.of(), ""),
    TF_API_ACCOUNT_QUERY_URL("114", "科目列表查询", "/tplus/api/v2/Account/Query", ListUtil.of(), ""),
    TF_API_INVENTORY_CLASS_QUERY_URL("115", "存货分类查询", "/tplus/api/v2/inventoryClass/Query", ListUtil.of(), "id,code," +
        "name"),
    TF_API_EXPENSE_VOUCHER_CREATE_URL("116", "费用单新增(新)", "/tplus/api/v2/expenseVoucher/Create", ListUtil.of(),  ""),
    // 采购入库单列表查询 tplus/api/v2/PurchaseReceiveOpenApi/FindVoucherList
    TF_API_PUR_RECEIVE_LIST_URL("117", "采购入库单列表查询", "/tplus/api/v2/PurchaseReceiveOpenApi/FindVoucherList",
        ListUtil.of(), ""),
    TF_API_PRODUCT_RECEIVE_CREATE_URL("116", "产成品入库单创建", "/tplus/api/v2/ProductReceiveOpenApi/Create", ListUtil.of(), ""),
    TF_API_OTHER_IN_STOCK_ORDER_CREATE_URL("118", "其他入库单创建", "/tplus/api/v2/OtherInStockOrderOpenApi/Create", ListUtil.of(), ""),
    TF_API_PUR_ARRIVAL_CREATE_URL("119", "进货单创建", "/tplus/api/v2/PurchaseArrivalOpenApi/Create", ListUtil.of(), ""),
    TF_API_SALES_OUT_LIST_URL("120", "销售出库单列表查询", "/tplus/api/v2/SaleDispatchOpenApi/FindVoucherList", SaleDispatch.saleDispatchList, ""),
    //销售订单列表查询 tplus/api/v2/SaleOrderOpenApi/FindVoucherList
    TF_API_SALES_ORDER_LIST_URL("121", "销售订单列表查询", "/tplus/api/v2/SaleOrderOpenApi/FindVoucherList",
        SaleOrderForRes.saleOrderList, ""),
    //费用单列表查询 tplus/api/v2/expenseVoucher/FindVoucherList
    TF_API_EXPENSE_VOUCHER_LIST_URL("122", "费用单列表查询", "/tplus/api/v2/expenseVoucher/FindVoucherList"
            ,Expensevoucher.expenseVoucherList, ""),
    // 采购订单列表查询 /tplus/api/v2/PurchaseOrderOpenApi/FindVoucherList
    TF_API_PUR_ORDER_LIST_URL("123", "采购订单列表查询", "/tplus/api/v2/PurchaseOrderOpenApi/FindVoucherList",PurchaseOrder.purchaseOrderList, ""),
    //  销货单创建 /tplus/api/v2/SaleDeliveryOpenApi/Create
    TF_API_SALE_DELIVERY_CREATE_URL("124", "销货单创建", "/tplus/api/v2/SaleDeliveryOpenApi/Create", ListUtil.of(), ""),


    ;
    private static final Map<String, TFApiEnum> LOOKUP_MAP = new HashMap<>(4, 1);

    static {
        for (TFApiEnum cstEnum : TFApiEnum.values()) {
            LOOKUP_MAP.put(cstEnum.codes, cstEnum);
        }
    }

    TFApiEnum(String codes, String name, String url, List<String> filedList, String filedString) {
        this.codes = codes;
        this.name = name;
        this.url = url;
        this.filedList = filedList;
        this.filedString = filedString;
    }

    /**
     * -- GETTER --
     *
     * @return 枚举值
     */
    private String codes;
    private String name;
    private String url;
    private List<String> filedList;
    private String filedString;


    /**
     * 根据枚举值获取枚举
     *
     * @param codes codes
     * @return 若枚举值存在，返回对应的枚举，否则返回 null
     */
    public static TFApiEnum formValue(String codes) {
        return LOOKUP_MAP.get(codes);
    }


}
